Quantcast
Channel: Aspose.Pdf Product Family
Viewing all 3131 articles
Browse latest View live

Aspose.Pdf Image null exceptions

$
0
0
Hi,

With the Aspose.Pdf.Generator namespace, if an image path didn't exist then the image would just not be put into the table in my Pdf and that was fine, but with the Aspose.Pdf namespace I get nullexceptions when images don't exist thrown on pdf.Save(memoryStreamContent);

Is there a way around this so I don't have to do a if (File.Exists(fileName)) {... check on all my images? Because that is slowing down the Pdf generation a fair amount.

Actually building the Pdf still works fine, it's the save that is not working.

Building the Pdf doesn't throw any exceptions, it's just when it gets saved to a stream.

LinkAnnotation not displaying in Chrome PDF Viewer

$
0
0
I am having an issue when I create a new Pdf.Page and add a FreeTextAnnotation to that new page. It is visible in Firefox and IE but not in Chrome, using its proprietary PDF viewer that runs by default in that browser. The LinkAnnotation that I create is clickable but the text of the FreeTextAnnotation is not visible in the Chrome Pdf viewer.

I am doing this in an asp.net application using the Aspose.Pdf dll. Is this a known issue with the Chrome PDF viewer or is there something I need in my code to make this work.

Here is the code:

//Create new document.            
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document();

Aspose.Pdf.Page linkPage = (Aspose.Pdf.Page)pdfDocument.Pages.Add();

// create Link annotation object
Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation link = new Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation(linkPage, new Aspose.Pdf.Rectangle(100, 300, 500, 750));

// create border object for LinkAnnotation
Aspose.Pdf.InteractiveFeatures.Annotations.Border border = new Aspose.Pdf.InteractiveFeatures.Annotations.Border(link);

// set the border width
border.Width = 0;
// set the border for LinkAnnotation
link.Border = border;

//Set the link url.
link.Action = new Aspose.Pdf.InteractiveFeatures.GoToURIAction("http://aspose.com");

// add link annotation to annotations collection of first page of PDF file
linkPage.Annotations.Add(link);

//create Free Text annotation
 Aspose.Pdf.InteractiveFeatures.Annotations.FreeTextAnnotation textAnnotation = new Aspose.Pdf.InteractiveFeatures.Annotations.FreeTextAnnotation(linkPage, new Aspose.Pdf.Rectangle(100, 300, 500, 750), "Link");

//Create text for link.
string strTextFrag = "Please click here to goto website.";

// String to be added as Free text
textAnnotation.Contents = strTextFrag;

// set the border for Free Text Annotation
textAnnotation.Border = border;

// add FreeText annotation to annotations collection of first page of Document
linkPage.Annotations.Add(textAnnotation);

return pdfDocument;



Thanks for any help you can provide!



Superscript bug

$
0
0
When there is a superscripted character in the text I'm pulling from a database, the Helevitica font I'm trying to use isn't respected. I believe it uses the Times New Roman font instead. Snippet below:

Table table = new Table();
            table.DefaultCellTextState.Font = FontRepository.FindFont("Helvetica");
            table.DefaultCellTextState.FontSize = 7;
            row = table.Rows.Add();
            row.DefaultCellPadding = new MarginInfo();
            row.DefaultCellPadding.Top = 6;
            row.DefaultCellPadding.Bottom = 6;
            row.DefaultCellBorder = border;
            row.IsRowBroken = false;

            row.Cells.Add(Db.getColumn<string>(dataRow, "description"));

How i can specify DefaultFontName for Document class

$
0
0
Hi,

In Aspose.Pdf.Generator.Pdf class we were using following properties. 

1. DefaultFontName
2. IsCoreFontUsed
3. IsTruetypeFontMapCached
4.TruetypeFontMapPath

How we can achieve similar functionality in Aspose.Pdf.Document class object.

Regards,
Sandeep

DOM API v. Generator API

$
0
0
We have a project where we are generating PDF files from scratch and are interested in using Aspose.Pdf as the engine for creating these documents.  In reading through your documentation, How to Use New Aspose.Pdf for .Net API it reads to me that the new DOM model is for modifying existing Pdf files while the older Generator model is still the API set used to create Pdf documents from scratch.

Aspose.Pdf.Generator

The old Aspose.Pdf for.NET (pre-6.0) provided the features to create new PDF file from scratch. As we have merged old Aspose.Pdf and Aspose.Pdf.Kit, all the classes previously available in old Aspose.Pdf for .NET have been moved under the Aspose.Pdf.Generator namespace. So, if you want to execute the old Aspose.Pdf code using the new product, use this namespace


Is this still the case that if I am generating documents from scratch I should be using the Generator API set?  If yes then I'm very concerned with regards to the last comment made to a issue I submitted in PDFNEWNET-35284, that the Generator is legacy and you are no longer being enhanced or corrected, aka not supported.  I need to know now if all this is accurate because I know of at least one enhancement we would like (ability to apply our own footnote label rather than have them automatically generated/numbered) and I know we would want corrections made if we were to encounter bugs.

Thanks,
Tim 

Pdf to Html CSS Prefix Problem

$
0
0
Hi,

I'm currently building something on the aspose.pdf convert to html functionality.

I'm using (among others) CssClassNamesPrefix on the HtmlSaveOptions object.
almost every css class is now automatically prefixed... except one: .view.
and precisely that one is interfering with the Html/CSS framework in which I'm showing the output-html (I'm also using HtmlMarkupGenerationModes.WriteOnlyBodyContent and adding the Html in some other page with existing html/css, hence the issue)

Is this a bug? Could this be fixed? Is there a workaround to change this during export?
Hope to hear from you.

Martin

Form Field Vertical Alignment Wrong

$
0
0
When filling in values of PDF form text fields the vertical alignment is wrong. It appears as if the alignment is getting set to bottom even though my code doesn't change it. I don't have this problem using Adobe Acrobat filling out the PDF.

My Sample Code is below and the sample file I used is attached.

Document pdfDocument = new Document("input.pdf");           // Get a field           TextBoxField textBoxField = pdfDocument.Form["textbox1"as TextBoxField;           TextBoxField codeField = pdfDocument.Form["CODE Field"as TextBoxField;           // Modify field value           textBoxField.Value = "S";           codeField.Value = "S";                   pdfDocument.Save("output.pdf");

which strategy?!

$
0
0
I need to generate a PDF, multiple pages. Besides an image, some normal text and background shapes, there are a couple non-standard texts:

  • a single line of text, horizontal, text rendering: 'Stroke text'
  • a single line of text, vertical (downwards), normal text rendering
  • multiple lines of text, horizontal, right-aligned, normal text rendering
  • a single line of text, horizontal, text rendering: 'Fill, then stroke text'
I have tried (and got stuck with) the following approaches:
  • Using the generator, I cannot find how to set text rotation
  • Using the document model with TextFragment, I cannot find how to set text rotation nor Text Rendering Mode
  • Using the document model with Operators, I can add a "SetTextRenderingMode" operator, but this is disfunctional - the actual value cannot be set.
btw. many of the Operators seem to be disfunctional. The true power of PDFs cannot be reached while these are disfunctional and so badly documented.

Any clues which PDF generation model I should use to be able to create such PDFs?

Thanks!

Pdf signing with a X509Certificate from a certificate sotre

$
0
0
Hi there,

I have read these posts and have the same problem.

Issue1:
http://www.aspose.com/community/forums/thread/608264/howto-sign-a-pdf-with-a-x509-certificate-from-certificate-store.aspx

Issue2:
http://www.aspose.com/community/forums/permalink/569295/569295/showthread.aspx#569295

The answer is the same in both, and refers na issue to be solved: PDFNEWNET-37412.

I just downloaded a trial and tested and the issue remains. Do you have any news about this? Will it be available soon?

Thank you very much.

Aspose.Pdf .Net Question

$
0
0

Hello, 

I’m a developer and I need the PDF library for .Net but I have few question:

If i buy Developer License:

-        1-I am working on TFS, can I use this library if I want put my code on TFS ?

-         2-  Aspose convert PDF to word properly, does it convert PDF to Excel or not ?
I have tried this code but its not working:

        ' Load PDF document

        Dim doc As Aspose.Pdf.Document = New Aspose.Pdf.Document(pu & _

            FileUpload1.FileName)

        ' Instantiate ExcelSave Option object


        'Dim excelsave As ExcelSaveOptions = New ExcelSaveOptions()


        ' Save the output in XLS format

        doc.Save(dest + FileUpload1.FileName + ".xls", excelsave)

        Response.Redirect("Successful_Convert_to_Excel.aspx?query2=" + FileUpload1.FileName)


-         3- Does it support Arabic language in converting from PDF to Word and Excel ?

FloatingBox with semi-transparent background

$
0
0
I need to create a FloatingBox with a semi-transparent background color, and the Aspose.Pdf.Color doesn't seem to respect the alpha value I'm providing. Here is my code:

public void FloatingBoxWithSemiTransparentBackground()
{
var pdf = new Document(@"c:\Temp\source.pdf");
var page = pdf.Pages[1];
var semiTransparentYellow = System.Drawing.Color.FromArgb(100, System.Drawing.Color.Yellow);
var asposeVersionOfYellow = Aspose.Pdf.Color.FromRgb(semiTransparentYellow);
var floatingBox = new FloatingBox(100, 200) { Left = 30, Top = 40, BackgroundColor = asposeVersionOfYellow };
page.Paragraphs.Add(floatingBox);
pdf.Save(@"c:\Temp\alpha_test.pdf");
}

The saved PDF does have the floating box in the right location and with the right RGB, but it is completely opaque.

How can I get the FloatingBox.BackgroundColor to respect alpha?

High Charts compatibility

$
0
0
Hi, 

I am currently trying to convert an html document to PDF using the aspose pdf library. However, when I open the PDF file, it does not seem to keep the highcharts that were in the html file. Instead it just has blank spaces on where they are supposed to be. I was wondering if there was a solution to this problem or if this has been addressed yet? 

Superscript bug

$
0
0
When there is a superscripted character in the text I'm pulling from a database, the Helevitica font I'm trying to use isn't respected. I believe it uses the Times New Roman font instead. Snippet below:

Table table = new Table();
            table.DefaultCellTextState.Font = FontRepository.FindFont("Helvetica");
            table.DefaultCellTextState.FontSize = 7;
            row = table.Rows.Add();
            row.DefaultCellPadding = new MarginInfo();
            row.DefaultCellPadding.Top = 6;
            row.DefaultCellPadding.Bottom = 6;
            row.DefaultCellBorder = border;
            row.IsRowBroken = false;

            row.Cells.Add(Db.getColumn<string>(dataRow, "description"));

The text is coming from a SQL Server database, and I've been noticing it with superscripts like trademark signs, exponents, copyrights etc.

<- Should be helvetica

In the meantime, how can I change the fallback to use Arial rather than Times New Roman?

Optimize Fonts when concatenating pdfs

$
0
0
Dear ladies and gentlemen,

In our application we have to combine several (eg 100) PDF files.
To optimize the resulting file we use this code:

pdfFileEditor.Concatenate(pdfStreams.ToArray(), packPdf);

packPdf.Seek(0, SeekOrigin.Begin);
var pdfDocument = new Document(packPdf);
foreach (Page page in pdfDocument.Pages)
{
var idx = 1;
foreach (XImage image in page.Resources.Images)
{
using (var imageStream = new MemoryStream())
{
image.Save(imageStream, ImageFormat.Jpeg);
imageStream.Seek(0, SeekOrigin.Begin);
page.Resources.Images.Replace(idx, imageStream);
}
idx = idx + 1;
}
}

// optimize the file size
pdfDocument.Optimize();
pdfDocument.OptimizeSize = true;
pdfDocument.OptimizeResources(new Document.OptimizationOptions
{
RemoveUnusedStreams = true,
RemoveUnusedObjects = true,
LinkDuplcateStreams = true
});
// save updated File
pdfDocument.Save(newPdfFileName);


After this optimization the size of the created pdf file is still too large. The cause of this is due to the fonts used in the source files.
The font definitions (/font-Dictionary and dependent objects) were taken for each original document into the target file.
If the /FileFonts2 streams are identical, only one stream was saved. If the streams are not identical, no union set of all required characters was formed.
The difference in file size, with an average size of the streams of 18.5 KB, is about 3 MB.

Is there a way to summarize the fonts efficiently?
Is such an implementation planed?

Best regards

Kind Regards,
Oliver

Aspose.Pdf Optimizing png Images

$
0
0
Hi there,

I used the follow code right before my pdf.save(memoryStream); call in an attempt to compress the images in the pdf:

pdf.OptimizeResources(new Document.OptimizationOptions()
{
    CompressImages=true,
    ImageQuality=10
});

Unfortunately the size of my document didn't change. Am I using the method wrong? The pdf is essentially a table and each row has a png image and some text.

The pdf comes to about 75MB right now.

Thanks

LinkAnnotation not displaying in Chrome PDF Viewer

$
0
0
I am having an issue when I create a new Pdf.Page and add a FreeTextAnnotation to that new page. It is visible in Firefox and IE but not in Chrome, using its proprietary PDF viewer that runs by default in that browser. The LinkAnnotation that I create is clickable but the text of the FreeTextAnnotation is not visible in the Chrome Pdf viewer.

I am doing this in an asp.net application using the Aspose.Pdf dll. Is this a known issue with the Chrome PDF viewer or is there something I need in my code to make this work.

Here is the code:

//Create new document.            
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document();

Aspose.Pdf.Page linkPage = (Aspose.Pdf.Page)pdfDocument.Pages.Add();

// create Link annotation object
Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation link = new Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation(linkPage, new Aspose.Pdf.Rectangle(100, 300, 500, 750));

// create border object for LinkAnnotation
Aspose.Pdf.InteractiveFeatures.Annotations.Border border = new Aspose.Pdf.InteractiveFeatures.Annotations.Border(link);

// set the border width
border.Width = 0;
// set the border for LinkAnnotation
link.Border = border;

//Set the link url.
link.Action = new Aspose.Pdf.InteractiveFeatures.GoToURIAction("http://aspose.com");

// add link annotation to annotations collection of first page of PDF file
linkPage.Annotations.Add(link);

//create Free Text annotation
 Aspose.Pdf.InteractiveFeatures.Annotations.FreeTextAnnotation textAnnotation = new Aspose.Pdf.InteractiveFeatures.Annotations.FreeTextAnnotation(linkPage, new Aspose.Pdf.Rectangle(100, 300, 500, 750), "Link");

//Create text for link.
string strTextFrag = "Please click here to goto website.";

// String to be added as Free text
textAnnotation.Contents = strTextFrag;

// set the border for Free Text Annotation
textAnnotation.Border = border;

// add FreeText annotation to annotations collection of first page of Document
linkPage.Annotations.Add(textAnnotation);

return pdfDocument;



Thanks for any help you can provide!



Secure pdf files in java

$
0
0

Hi,

I am facing issue on production about secure document. Please find below questions-

Users are uploading Secured document and normal pdf documents by applications.

Normal pdf documents are working properly. Bur facing issues only for secured documents. I am not giving any password for opening secured PDF documents.

I checked secured pdf file properies -

On security section it is showing

a. Security method = Password Security

b. Document Open password = No

c. Permission password = Yes

we are using aspose jars and Itext jars for reading and uploading PDF document.

1. How can we check whether document is secured or not in java program

2. How we can convert Secured to Unsecured or Unlock the documents.

Could you please suggest to me and provide the code?

Regards,

RSY

 

 

 

 

HTML TO PDF Conversion issue

$
0
0

Hi,

Currently, I am evaluating HTML to PDF conversion using Aspose.PDF 7.2. Below are the couple of requirements which we would like to take in to consideration.

  • 1.       Image & CSS Support during conversion
  • 2.       Tables & Input Controls Support.
  • 3.       Page Breaking (In case when rendered HTML has scrollbar in it. It should page break accordingly when HTML is long enough.)

Could you let us know which the recommended way to achieve above mentioned requirements.


Moreover, below are the couples of approaches we have tried out with attached HTML pages to convert it to PDF but none of them succeeded so far. With each approach we are getting below mentioned exception.

Exception:

An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll.

Inner Exception: {Unable to evaluate expression.}


Approach 1 (Using Aspose 7.2): Getting same Exception mentioned above.

Dim a As Byte() = My.Resources.Aspose_Total

        Dim m_Stream As MemoryStream = Nothing

        Dim pdfDocumentGenerator = New Aspose.Pdf.Generator.Pdf()

        Dim modifiedFilePath As String = destPath + "\ResultMultiPageFile" + ".PDF"

        Try

            Dim memLicense As System.IO.MemoryStream

            Dim licPDF As Aspose.Pdf.License = New Aspose.Pdf.License()

            memLicense = New System.IO.MemoryStream(a)

            licPDF.SetLicense(memLicense)

 

            If Not System.IO.Directory.Exists(destPath) Then

                System.IO.Directory.CreateDirectory(destPath)

            End If

 

            If System.IO.File.Exists(modifiedFilePath) Then

                System.IO.File.Delete(modifiedFilePath)

            End If

 

            For Each FilePath As String In FileNames

                Dim BasePath As String = System.IO.Path.GetDirectoryName(FilePath)

                Dim m_HTMLLoadOption As New Aspose.Pdf.HtmlLoadOptions(BasePath)

                Dim PDFDOc As New Aspose.Pdf.Document(FilePath, m_HTMLLoadOption)

                PDFDOc.Save(modifiedFilePath)

            Next

 

        Catch ex As Exception

            Throw ex

        Finally

            If m_Stream IsNot Nothing Then m_Stream.Dispose()

        End Try

 

Approach 2 (Using Aspose 7.2):  Getting same Exception mentioned above.

Dim a As Byte() = My.Resources.Aspose_Total
        Dim m_Stream As MemoryStream = Nothing
        Dim pdfDocumentGenerator = New Aspose.Pdf.Generator.Pdf()
        Dim modifiedFilePath As String = destPath + "\ResultMultiPageFile" + ".PDF"
        Try
            Dim memLicense As System.IO.MemoryStream
            Dim licPDF As Aspose.Pdf.License = New Aspose.Pdf.License()
            memLicense = New System.IO.MemoryStream(a)
            licPDF.SetLicense(memLicense)
            If Not System.IO.Directory.Exists(destPath) Then
                System.IO.Directory.CreateDirectory(destPath)
            End If
            If System.IO.File.Exists(modifiedFilePath) Then
                System.IO.File.Delete(modifiedFilePath)
            End If
            For Each FilePath As String In FileNames
                pdfDocumentGenerator.HtmlInfo.CharSet = "UTF-8"
                ' load the HTML file to Stream object
                pdfDocumentGenerator.BindHTML(System.IO.File.ReadAllText(FilePath))
                pdfDocumentGenerator.Save(modifiedFilePath)
            Next
        Catch ex As Exception
            Throw ex
        Finally
            If m_Stream IsNot Nothing Then m_Stream.Dispose()
        End Try

 

Approach 3 (Using Aspose 7.2):  Getting same Exception mentioned above.

Dim a As Byte() = My.Resources.Aspose_Total
        Dim m_Stream As MemoryStream = Nothing
        Dim pdfDocumentGenerator = New Aspose.Pdf.Generator.Pdf()
        Dim modifiedFilePath As String = destPath + "\ResultMultiPageFile" + ".PDF"
        Try
            Dim memLicense As System.IO.MemoryStream
            Dim licPDF As Aspose.Pdf.License = New Aspose.Pdf.License()
            memLicense = New System.IO.MemoryStream(a)
            licPDF.SetLicense(memLicense)
            If Not System.IO.Directory.Exists(destPath) Then
                System.IO.Directory.CreateDirectory(destPath)
            End If
            If System.IO.File.Exists(modifiedFilePath) Then
                System.IO.File.Delete(modifiedFilePath)
            End If
            For Each FilePath As String In FileNames
                ' add the section to PDF document sections collection
                Dim section As Aspose.Pdf.Generator.Section = pdfDocumentGenerator.Sections.Add()
                ' Read the contents of HTML file into StreamReader object
                'Dim r As StreamReader = File.OpenText(FilePath)
                'Create text paragraphs containing HTML text
                Dim text2 As Aspose.Pdf.Generator.Text = New Aspose.Pdf.Generator.Text(section, System.IO.File.ReadAllText(FilePath))
                ' enable the property to display HTML contents within their own formatting
                text2.IsHtmlTagSupported = True
                ' Add the text object containing HTML contents to PD Sections
                section.Paragraphs.Add(text2)
                ' Specify the URL which serves as images database
                pdfDocumentGenerator.HtmlInfo.ImgUrl = System.IO.Path.GetDirectoryName(FilePath)
            Next
            pdfDocumentGenerator.Save(modifiedFilePath)
        Catch ex As Exception
            Throw ex
        Finally
            If m_Stream IsNot Nothing Then m_Stream.Dispose()
        End Try

 

Could you suggest recommended way to do this?

Converting HTML to PDF

$
0
0
Hi,

We are not being able to convert the attached HTML file to PDF using any of the API methods mentioned in the documentation.

We are using the latest Aspose.PDF dll version - 10.3. Kindly let us know the reason for this. We observed that even a simple style tag in the HTML for certain elements results in an exception in PDF conversion. If so, can we get an exhaustive list of what is supported and what is not ?

If you are able to convert this to PDF, kindly let us know the steps/API methods that you used for the same.

How to set the security for an existing PDF document.

$
0
0
Dear Team,

I want to set security for an existing PDF document.

As part of it. I want to disable the Editing, disable adding images, and want to disable extracting the PDF document to any other file formats.

Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(docLocation);
 DocumentPrivilege documentPrivilege = DocumentPrivilege.ForbidAll;
           documentPrivilege.AllowScreenReaders = true;
            documentPrivilege.AllowPrint = true;
            documentPrivilege.AllowCopy = true;
            
            pdfDoc.Encrypt("", "asc", documentPrivilege, CryptoAlgorithm.AESx256, false);
            
             pdfDoc.Save(docLocation);

Having used the above code I am actually able to forbid the user from editing the document. But I am not able to forbid the user from extracting the PDF document to any other file formats.

Could you please give a sample code to achieve this functionality.

Regards,
Rajesh
Viewing all 3131 articles
Browse latest View live