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

Getting JPEG image to fit in whole PDF page during conversion.

$
0
0
Hi,

I am having problem when converting images specifivally JPEG (in binary format) to PDF. The approach I am using here is by converting an image binary string to Memory Stream then convert them to PDF. 

Just wanted to clarify here that this JPEG has previously been converted from PDF which I suppose has the same page ratio as a PDF one. (I have my reason to convert it to JPEG first then to PDF but not straight from Words to PDF).

When I attempt to convert this JPEG image. Then the resultant PDF does not take the image as a whole page, in fact, it is treated like an image embeded in PDF instead, which the image just concentrate at the middle of the PDF page. What should I do in order to get the whole image to fit a full PDF page? Here I share my code snippet for the conversion and the resultant PDF in attachment. Please advice. Thank you.

[C#]
                Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
                MemoryStream ms = new MemoryStream();
String attmimetype = "";
//query to retrieve binary content and mimetype
                String Sql = String.Format("select Content, mimetype from SourceTable where SourceId = '{0}'", Guid);

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString))
                {
                    SqlDataReader myReader = null;
                    conn.Open();
                    SqlCommand myCommand = new SqlCommand(Sql, conn);
                    myReader = myCommand.ExecuteReader();
                    while (myReader.Read())
                    {
attmimetype = myReader["mimetype"].ToString();
                        Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
                        Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);

                        switch (attmimetype)
                        {
                            case "image/jpeg":
                                image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
                                break;

                            case "image/gif":
                                image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Gif;
                                break;

                            case "image/png":
                                image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Png;
                                break;

                            case "image/bmp":
                                image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Bmp;
                                break;
                        }
                        image1.ImageInfo.FixWidth = sec1.PageInfo.PageWidth - sec1.PageInfo.Margin.Left - sec1.PageInfo.Margin.Right;
                        ms = new MemoryStream((byte[])myReader["Content"]);
                        image1.ImageInfo.ImageStream = ms;
                        sec1.Paragraphs.Add(image1);
                    }
                }
String OutputPath = "C:\\output.pdf";
                pdf1.Save(OutputPath);
                ms.Close();

Display the Merged PDF

$
0
0

Hi,

We are using Aspose.PDF 9.1 for our customer. We currently execute SQL server reporting service reports for selected records and then convert resulting report for each record into PDF from Memory stream (i.e. we do not save it on disc) using Aspose.PDF.Document, and finally merge all PDF files into single PDF and  attach the output single PDF to another record in their CRM system.

Our new requirement is to display the single output PDF on users machine. How can we do this?

 

Thanks

 

PDFInfo needs to be plaintext

$
0
0
All day long, I have been producing PDFs by filling a PDF form and merging PDFs, optimizing size, etc, and I can search for "Keywords" in the document in notepad and find and read it. Now I changed something and that section has been compressed into an unreadable binary mess. How can I keep the Author, Keywords, etc fields above the FlateDecode section?

Validate PDF/A Nullpointer Exception on some Linux Systems

$
0
0
Hi,

I need to validate our PDF to his PDF/A 1-b or 1-a compliance (an old story)

The libs I tried are Aspose.Pdf 4.6.0 and also 9.0.0 with the same issue.

Here is the code:
/* LOAD AsposeTotal Lic */

com.aspose.pdf.Document doc = new com.aspose.pdf.Document(new ByteArrayInputStream(file));

boolean validate = doc.validate(new ByteArrayOutputStream(), PdfFormat.PDF_A_1B);

This code works fine on Windows 7 64bit with Java 7 and also on different linux systems like ubuntu 14.04 and some older RedHat 5.1 installations.

On production and test systems I get this error:
Exception in thread "main" java.lang.NullPointerException
     at com.aspose.pdf.b.c.g.d.l.a(Unknown Source)
     at com.aspose.pdf.b.c.g.d.l.parse(Unknown Source)
     at com.aspose.pdf.b.c.g.d.n.a(Unknown Source)
     at com.aspose.pdf.b.c.g.d.n.a(Unknown Source)
     at com.aspose.pdf.b.c.g.d.n.deV(Unknown Source)
     at com.aspose.pdf.b.c.g.d.n.<init>(Unknown Source)
     at com.aspose.pdf.b.c.g.d.n.<init>(Unknown Source)
     at com.aspose.pdf.b.j.a.b.a(Unknown Source)
     at com.aspose.pdf.b.j.a.b.dkI(Unknown Source)
     at com.aspose.pdf.b.j.a.b.a(Unknown Source)
     at com.aspose.pdf.ADocument.convert(Unknown Source)
     at com.aspose.pdf.Document.convert(Unknown Source)
     at com.aspose.pdf.ADocument.t(Unknown Source)
     at com.aspose.pdf.Document.t(Unknown Source)
     at com.aspose.pdf.ADocument.validate(Unknown Source)
     at com.aspose.pdf.Document.validate(Unknown Source)
     at it.siag.pdf.agent.PdfAgent.isValidPdfAFile(Unknown Source)
     at it.siag.pdf.agent.PdfAgentMain.main(Unknown Source
The system I use is the following:
Red Hat Enterprise Linux Server release 6.5 (Santiago)
Linux xxxxxxx 2.6.32-431.5.1.el6.x86_64 #1 SMP Fri
java: jdk1.7.0_55 (64bit oracle)
I also tried to launch my testclient with sudo with same error.

With this Stacktrace I don't have any idea which can be the problem, your libs will do something which goes wrong on some linux systems, but I have no idea what else to test.

thx
  Michael

USPS IMB Standard Barcode Font - Spacing Issue

$
0
0

I am trying to add text to a PDF document, and that part works fine.  The issue, though, is when I try and add text using the USPS Intelligent Mail Barcode font.  The font works correctly in word, but when using a text fragment to add it to the PDF, it includes random spaces.  I am attaching the starting sample document, the USPS Font, and the output document.  The code I am using is below.

Please let me know if there is a fix.  Thanks!

 

        Const ASPOSE_LICENSE_PATH_Pdf As String = "P:\WizClient\License\Aspose.Pdf.lic"
        Dim licensePDF As Aspose.Pdf.License = New Aspose.Pdf.License()
        licensePDF.SetLicense(ASPOSE_LICENSE_PATH_Pdf)

        Dim doc As Document = New Aspose.Pdf.Document("C:\t\sample.pdf")
        Dim page As Page = doc.Pages(1)
        Dim builder As TextBuilder = New TextBuilder(page)

        Dim textFragment As New TextFragment("TDTFATTTAFTFADDDDAAFFDATTFFTTTFAADATFATDDAFDFDATATDFADADTFDFFFDTF")
        textFragment.Position = New Position(60, 675)
        textFragment.TextState.FontSize = 16
        textFragment.TextState.Font = FontRepository.FindFont("USPSIMBStandard")
        textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Transparent)
        textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black)
        builder.AppendText(textFragment)

        Dim paragraph As TextParagraph = New TextParagraph()
        paragraph.Rectangle = New Aspose.Pdf.Rectangle(60, 600, 600, 700)
        paragraph.FormattingOptions.WrapMode = Aspose.Pdf.Text.TextOptions.TextFormattingOptions.WordWrapMode.ByWords
        Dim fragment1 As TextFragment = New TextFragment("Mr. Don Julio El Guappo" & vbCrLf & "400 Milford Parkway" & vbCrLf & "Milford, OH  45176-9114")
        fragment1.TextState.Font = FontRepository.FindFont("Times New Roman")
        fragment1.TextState.FontSize = 9
        paragraph.AppendLine(fragment1)
        builder.AppendParagraph(paragraph)

        If System.IO.File.Exists("C:\t\output.pdf") Then
            System.IO.File.Delete("C:\t\output.pdf")
        End If
        doc.Save("C:\t\output.pdf")
        Process.Start("C:\t\output.pdf")

 

Create PDF file from an array of images, each image in the array being a byte[]

$
0
0
Hello,

I would like to take an array of images, say a List<byte[]> Images  and then create a pdf file using this array of images.

What would be the best way to create the PDF File and then get the byte[] of that PDF file to pass back to the calling application.

This should be done in the best way possible for memory management, I would like to create and dispose of a memory stream for each page as it goes to keep memory usage down :

[Psudo Code C#]
var PDFFile = Aspose.Pdf.....
foreach(byte[] imageByteArray in ArrayOfImageByteArrays)
{
using(MemoryStream imageMS = new MemoryStream(imageByteArray))
{

//Add image to PDF file as a page here

}
}

//Done, so save complete PDF File to another memory stream so we can get the byte array
using(MemoryStream fileMS = new MemoryStream())
{
    pdfFile.Save(fileMS);
    ByteArrayToReturn = fileMS.toArray();
}

Pleae use version number in the jar file

$
0
0
When you create new version zip file, can you use version number for the jar file?
I have to rename the jar file.

Thanks,
Chang Shin

Radio button values

$
0
0
I'm attempting to read the value of a radio button on an existing document with Aspose.Pdf version 8.8.  The document was created by Adobe LiveCycle with reader extensions and contains approximately 50 fields.

Aspose.Pdf.Document.Form.Fields property (only contains 3 digital signature fields)
Aspose.Pdf.Document.Form.GetField method (returns values for fields except radio buttons)
Aspose.Pdf.Facades.Form.ExportXml method (result includes values for all fields except radio buttons)
Aspose.Pdf.Facades.Form.GetFieldFacade method (no suitable parameter value found)
Aspose.Pdf.Facades.Form.GetButtonOptionCurrentValue method (no suitable parameter value found)


How to get the page number of a Destination (in a GoToAction Annotation)

$
0
0
I'm examining a PDF that has been supplied to me. It contains internal hyperlinks (i.e. hyperlinks that take you to other pages within the document). For each hyperlink, I want to know the page number of the page it takes you to.

At the moment I'm looking at the Annotations property for each page: this gives me a list of hyperlinks on that page. I look at each one's Action. Where it is a GoToAction, I examine the Destination.

What I'm finding is that the Destination is a NamedDestination, for example with the Name "appendix-a".

What I want is the page number of the NamedDestination called "appendix-a". How can I get this?

Thanks.

Cell border issues when table spans pages

$
0
0
Hi,

I am currently generating PDF documents via XSLT and XML using the Pdf.BindXML method. The PDF has a number of large tables which span over pages.

I am finding that often the first and sometimes last data row of a table can be corrupted in relation to the vertical position and border. It seems to change depending on how much text precedes the table. Sometimes it is just the vertical position that is wrong and other times I also get a double cell/row border as in the attachment.

I have attached a sample xslt and sample xml data that recreates the error. I have also attached the resulting pdf output. You can see the error in the first and last data row on page 2 (excluding header row).

Is there something I'm missing in the xslt or is there something wrong in the Pdf.Generator?

I am using the 9.2.1.0 version of the Aspose.Pdf library and used the following test code to generate the pdf:
var pdf1 = new Pdf();
var license = new License();
license.SetLicense("Aspose.Pdf.lic");
pdf1.BindXML(@"D:\test-data.xml"@"D:\test-template.xslt");
pdf1.Save(@"D:\test-output.pdf");

JasperReports reports services vs Aspose.PDF for JasperReports

$
0
0
Hi,
I trying to understand what are the advantages of using Aspose.PDF for JasperReports instead of "pure" JasperReports..
I have a lot of JasperReports now and facing a big performance issue - server fails after 10-15 report generations and JasperReports support doesn't actually helps.. 
I'd like to see some comparison table too.
Thank you in advance!

Re: How to limit memory usage when extracting text from large PDFs?

$
0
0
Has there been any change in this issue?  I am facing exactly the same problem.

Unable to lock pdf from copy and print

$
0
0
Hello Aspose Team,
I was trying to lock a pdf file from copying and printing using the link from your documentation.
How ever I was able to lock a user from doing so in adobe pdf and Google chrome. But, if I open the same file in firefox I was able to copy as well as print the pdf document.

Code I used is as follows
                DocumentPrivilege privilege = DocumentPrivilege.ForbidAll;
                privilege.ChangeAllowLevel = 1;
                privilege.AllowPrint = false;
                privilege.AllowCopy = false;

                PdfFileSecurity fileSecurity = new PdfFileSecurity(textBox1.Text,
                    Environment.CurrentDirectory + @"\output.pdf");

                fileSecurity.SetPrivilege(privilege);


PdfFileEditor keeps a reference to concatenated files

$
0
0
Hi,
I am using Aspose.Pdf version 9.2.1 and I have this piece of code that concatenates PDF files into a single one. For my scenario I used only one very big pdf document, just for simplicity. However, I tried with multiple PDF documents (one very large and another one very small) and I get the same issue.

List<string> convertedFiles = new List<string>();

convertedFiles.Add(Pdf_path);

Aspose.Pdf.Facades.PdfFileEditor pdfEditor = new PdfFileEditor();           pdfEditor.Concatenate(convertedFiles.ToArray(), _pdfPath);

The PDF file has 250 MB in size.

After concatenation I try and delete that file but get an exception: 

File cannot be deleted because it is being used by another process.

I then tried to close the streams using: 

pdfEditor.CloseConcatenatedStreams = true;  

but with no luck.

However, it works fine with small PDF files.

Can you reproduce this on your side ?

Thanks,
Andrei

skip a particular page from being printefd

$
0
0
Hi,
I have a 15 page PDF document and i want to skip the 5th and 10th page from being printed. How to do this using Aspose.Pdf?

AsposePDF 8.5 not printing the correct size.

$
0
0

Dear Aspose,

I am having difficulties printing a PDF in its true size. I am working on 2008 server, with aspose 8.5. See the attachments for PDF and my code.

No matter what i try (margins to 0, printasimage, autoscale on/off, other printer...), PDF's are always printed about 50-75% smaller than when printed with a pdfreader.

Could you please advise me?

Regards,


Nathan Moerman

 

Digital signature in PDF

$
0
0
Hi, I am trying to write a PDF document using PDF template. The PDF template has "Signing" set as allowed. The output PDF has "Signing" set as NOT allowed. This is stopping progress in my work as the output pdf has to be digitally sign-able. Please share a sample code snippet if possible.
Please help.Thanks in Advance.

Regards,
Development team

How do you stop words from being split across two lines

$
0
0
Dear Team

We have an issue in using Aspose.pdf. We need to convert HTML to PDF. The issue is words are getting split to next lines. Attaching the code & sample output for reference. Please help

Code

 

Dim pdf As Aspose.Pdf.Generator.Pdf = New Aspose.Pdf.Generator.Pdf()

 

                       'set the license file

                       Dim lic AsNew Aspose.Pdf.License()

                        lic.SetLicense(System.Web.HttpContext.Current.Server.MapPath("AsposeLicense/Aspose.Total.lic"))

 

                       ' add the section to PDF document sections collection

                       Dim section As Aspose.Pdf.Generator.Section = pdf.Sections.Add()

 

                        section.PageInfo.PageWidth = Aspose.Pdf.Generator.PageSize.LetterWidth

                        section.PageInfo.PageHeight = Aspose.Pdf.Generator.PageSize.LetterHeight

 

 

 

                       Dim marginInfo As Aspose.Pdf.Generator.MarginInfo = New Aspose.Pdf.Generator.MarginInfo()

                        marginInfo.Top = 0

                        marginInfo.Bottom = 0

                       marginInfo.Left = 0

                        marginInfo.Right = 0

 

                       Dim marginInfotext As Aspose.Pdf.Generator.MarginInfo = New Aspose.Pdf.Generator.MarginInfo()

                        marginInfotext.Top = 95

                        marginInfotext.Bottom = 95

                        marginInfotext.Left = 35

                        marginInfotext.Right = 35

 

                        section.PageInfo.Margin = marginInfotext

 

                       Dim txt1 As Aspose.Pdf.Text.TextFragment = New Aspose.Pdf.Text.TextFragment()

                        txt1.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Justify

 

                       Dim graph1 As Aspose.Pdf.Generator.Graph = New Aspose.Pdf.Generator.Graph(section)

                        graph1.Margin.Top = 0

                        graph1.Margin.Bottom = 0

                        section.Paragraphs.Add(graph1)

                                             

                        Dim text As Aspose.Pdf.Generator.Text = New Aspose.Pdf.Generator.Text(section, sHtml)

                       

 

                        text.IsHtmlTagSupported = True

 

                        section.Paragraphs.Add(text)

                        section.IsSpaced = True

 

                       'set page size

                        pdf.PageSetup.PageWidth = Aspose.Pdf.Generator.PageSize.LetterWidth

                        pdf.PageSetup.PageHeight = Aspose.Pdf.Generator.PageSize.LetterHeight

 

                       

                        pdf.PageSetup.Margin = marginInfo

 

                        pdf.Save(sTempPDF)

 

 

HTML Source sHtml =

 

<html><body><table cellspacing="2.50cm" width="100%"><tbody><tr><td><p></p><p><br /></p><p style="margin-top: 0px;margin-bottom: 0px;">1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;is&nbsp;an&nbsp;example&nbsp;of&nbsp;a&nbsp;decision,&nbsp;including&nbsp;special&nbsp;characters&nbsp;like&nbsp;"ô"&nbsp;and&nbsp;"í"&nbsp;and&nbsp;"ã"&nbsp;and&nbsp;other&nbsp;features&nbsp;(like&nbsp;parentheses)&nbsp;and&nbsp;a&nbsp;noun's&nbsp;possessive&nbsp;forms.&nbsp;--</p><p><br /></p><p style="margin-left: 0.5in;margin-top: 0px;margin-bottom: 0px">a.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Some&nbsp;parts&nbsp;of&nbsp;the&nbsp;text&nbsp;will&nbsp;need&nbsp;to&nbsp;be&nbsp;indented.</p><p><br /></p><p style="margin-left: 1in;margin-top: 0px;margin-bottom: 0px">i).&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;some,&nbsp;even&nbsp;further;</p><p><br /></p><p style="margin-top: 0px;margin-bottom: 0px;">2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;All&nbsp;paragraphs&nbsp;will&nbsp;also&nbsp;need&nbsp;a&nbsp;tab&nbsp;character&nbsp;between&nbsp;the&nbsp;number&nbsp;and&nbsp;text,&nbsp;which&nbsp;transfers&nbsp;to&nbsp;the&nbsp;IR&nbsp;intact,&nbsp;and&nbsp;paragraph&nbsp;breaks&nbsp;between&nbsp;each.</p><p></p><p><br /></p><p></p><p><br /></p></td></tr></tbody></table></body></html>

Thanks
Anish

Save / print XFA form

$
0
0
Hi, 

We are using a lot of XFA forms which we created with Adobe LiveCycle Designer. In our application we sometimes need to print these forms. I'm trying to do this with the aspose.pdf and followed instructions from this page:

http://www.aspose.com/docs/display/pdfnet/Convert+Dynamic+XFA+form+to+Standard+AcroForm 

However, when i save the form as instructed above and retrieve the file it has the page where is says: Please wait... if this message is not eventually replace by... etc etc. 

My code: 
Dim pdfdoc As New Aspose.Pdf.Document(xfa_filename) 
pdfdoc.Form.Type = FormType.Standard 
pdfdoc.Save(new_filename) 

What am i missing? 
Regards, Jacob

OptimizeResources bug

$
0
0
I thought I posted this before, but I can't find it now. We have a complex form (over 200 fields) that we are filling (HFCA for medical billing), and we discovered that if we optimize resources on a document containing fields, the document is silently corrupted by replacing some fields with other fields, so that info is incorrectly duplicated in multiple locations. We have to wait until after a form as been flattened, and even then, I am somewhat nervous to use this feature.
Viewing all 3131 articles
Browse latest View live