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

Setting a background image

$
0
0
Using Aspose.PDF 10.5.1 I am trying to create a pdf file using the Aspose.Pdf.Generator.Pdf and I am having some trouble setting a background image.

I can use the Section.BackgroundImageFile to set images as I create my various sections, but I can't set the image height when I do this so and I don't want my image to fill the entire page.

I've tried loading my Generator into a Document object and then using either Stamps of BackgroundArtifacts but I can't get either to work. The final pdf is still the same size as if I had just written out the Generator output. Can I get some pointers? Thanks!

Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

AddLetterPage(pdf1, letter_info);

Document doc = new Document(pdf1);

foreach(Page page in doc.Pages)
{
/*BackgroundArtifact bga = new BackgroundArtifact();
bga.BackgroundImage = System.IO.File.OpenRead(image_path);
bga.ArtifactVerticalAlignment = VerticalAlignment.Center;
bga.ArtifactHorizontalAlignment = HorizontalAlignment.Center;

page.Artifacts.Add(bga);*/

ImageStamp stamp = new ImageStamp(image_path);
stamp.Background = true;
stamp.VerticalAlignment = VerticalAlignment.Center;
stamp.HorizontalAlignment = HorizontalAlignment.Center;

page.AddStamp(stamp);
}

System.IO.MemoryStream ms_pdf = new System.IO.MemoryStream();
doc.Save(ms_pdf);

Aspose.Pdf for .NET Validation Error

$
0
0
While evaluating your product "Aspose.Pdf for NET" we have come accross a problem. We are converting PDF documents to PDF/A-2a as recommended in the examples. However, when we used the validation tool from http://www.pdf-tools.com/pdf/validate-pdfa-online.aspx we received an error message with all the tested documents. The error message and the converted documents are in the attachment.
We would appreciate if you could clarify the matter for us as we would like to purchase this product and cannot do so without knowing why the problem occurred.

Thank you for your time.


Here is the file, but I want to stress that it doesn’t matter wich file I use. The result is always the same.

IsKeptWithNext issue

$
0
0
Hello,

We found the weird issue with IsKeptWithNext property. In our document there is a heading and some related text (or table) paragraphs. The requirement is do not split the heading and its first paragraph and keep them on the same page. In other words it should not be a lonely heading at the bottom of the page. To achieve this we tried to set IsKeptWithNext = true to the heading.

Here there are 2 samples:

1) Everything works as expected (the "Heading 3" is rendered on the next page together with the 1st text paragraph):

            Pdf document = new Pdf();
            Section docPage = document.Sections.Add();
            docPage.PageInfo.Margin = new MarginInfo()
            {
                Bottom = 30,
                Left = 0,
                Right = 0,
                Top = 0
            };
            Heading h = new Heading(document, docPage, 1);
            h.Segments.Add(new Segment("Heading 2"));
            docPage.Paragraphs.Add(h);
            for (int i = 0; i < 65; i++)
            {
                docPage.Paragraphs.Add(new Text(docPage, "test test test " + i.ToString()));
            }

            // HEADING 3
            h = new Heading(document, docPage, 1)
            {
                IsKeptWithNext = true
            };
            h.Segments.Add(new Segment("Heading 3"));
            docPage.Paragraphs.Add(h);
            for (int i = 0; i < 75; i++)
            {
                docPage.Paragraphs.Add(new Text(docPage, "test test test " + i.ToString()));
            }
            
            document.Save("output_1.pdf");

2) Now we add a page before "Heading 2" and set "Heading 2" as the first paragraph of the page. The result is unexpected: "Heading 3" and its 1st text paragraph are split and displayed on different pages. Moreover in both cases the page margin top is 0 so the rendering starts from the beginning of the page. It seems that if there is any page break before "Heading 2", the property  "IsKeptWithNext " for all heading below is ignored (or the start point is not calculated properly). For us it's the critical bug.

    Pdf document = new Pdf();
            Section docPage = document.Sections.Add();
            docPage.PageInfo.Margin = new MarginInfo()
            {
                Bottom = 30,
                Left = 0,
                Right = 0,
                Top = 0
            };

            // HEADING 1
            Heading h = new Heading(document, docPage, 1);
            h.Segments.Add(new Segment("Heading 1"));
            docPage.Paragraphs.Add(h);
            for (int i = 0; i < 10; i++)
            {
                docPage.Paragraphs.Add(new Text(docPage, "test test test " + i.ToString()));
            }

            // HEADING 2 (New Page)
            docPage.PageInfo.Margin = new MarginInfo()
            {
                Bottom = 30,
                Left = 0,
                Right = 0,
                Top = 0
            };
            h = new Heading(document, docPage, 1);
            h.IsFirstParagraph = true;
            h.Segments.Add(new Segment("Heading 2"));
            docPage.Paragraphs.Add(h);
            for (int i = 0; i < 65; i++)
            {
                docPage.Paragraphs.Add(new Text(docPage, "test test test " + i.ToString()));
            }

            // HEADING 3
            h = new Heading(document, docPage, 1)
            {
                IsKeptWithNext = true
            };
            h.Segments.Add(new Segment("Heading 3"));
            docPage.Paragraphs.Add(h);
            for (int i = 0; i < 75; i++)
            {
                docPage.Paragraphs.Add(new Text(docPage, "test test test " + i.ToString()));
            }
            
            document.Save("output_2.pdf");

In the attachment there are 2 outputs for the scenarios above.
Please advise.

Issue with table rowspan and colspan in aspose .net pdf

$
0
0

I am always getting issue with aspose tables if it have rowspan immediate to colspan in the table.

It have always cells are misplaced/ wrongly arranged.

Below is my sample table mark up and my code.

Markup :

<table><tbody><row><entry colspan="1">Column1 and column2 merge With Colspan1</entry><entry rowspan="1" name"col3">Column3 With Rowspan1</entry></row><row><entry name="col1">Column1 for row 2</entry><entry name="col2">Column2 for row 2</entry></row></tbody></table>

code :

Aspose.Pdf.Table table = new Aspose.Pdf.Table();

        //Set with column widths of the table
        table.ColumnWidths = "150 150 150";

        table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 2F, Aspose.Pdf.Color.Blue);

Row row1 = table.Rows.Add();

        Cell cell1 = row1.Cells.Add("Column1 With Colspan1");
        cell1.ColSpan = 2;
        cell1.Border = new BorderInfo(Aspose.Pdf.BorderSide.All, 1.0f, Aspose.Pdf.Color.Red);
        cell1.IsWordWrapped = true;

        Cell cell2 = row1.Cells.Add("Column2 With Rowspan1");
        cell2.RowSpan = 2;
        cell2.Border = new BorderInfo(Aspose.Pdf.BorderSide.All, 1.0f, Aspose.Pdf.Color.Green);
        cell2.IsWordWrapped = true;

        Row row2 = table.Rows.Add();

        Cell r2c1 = row2.Cells.Add("Column1 for row 2");
        r2c1.Border = new BorderInfo(Aspose.Pdf.BorderSide.All, 1.0f, Aspose.Pdf.Color.Black);
        r2c1.IsWordWrapped = true;

        Cell r2c2 = row2.Cells.Add("Column2 for row 2");
        r2c2.Border = new BorderInfo(Aspose.Pdf.BorderSide.All, 1.0f, Aspose.Pdf.Color.Yellow);
        r2c2.IsWordWrapped = true;


        pdfPage.Paragraphs.Add(table);

Images flipped on document conversion

$
0
0
Hi,

I have noticed one issue while using Aspose.PDF to convert a PDF to a word document.
The input PDF contained a scanned document with multiple images, but in the converted word document, all of the images have been reversed.

The output document is basically a mirror image of the input PDF.
I have attached the input and output documents here.

Horizontal Line not rendering using java aspose pdf

$
0
0
Hi I am crated pdf using Document object. (using HtmlFragment class). I want to change horizontal line background color. 
but if i give color code  in html content  also not showing <hr> line color

Set Characters per horizontal and vertical inch

$
0
0
Hi,

I wanted to check if in aspose there is a way to set characters per horizontal inch and lines per vertical inch.

Regards,

Html to PDF shows ? when html has &nbsp;

$
0
0
Html to PDF conversion shows black color question mark (?) when html has &nbsp; in the code. Kindly let know how to fix this or if it is a bug.

TextParagraph text overriden

$
0
0
Hi,

If text goes more than one page, it overrides the content in that same page rather than adding another page. How can I change it so that pages are added dynamically as needed?

Below is my sample code. The output had one pdf page added showing numbers from 160 through 199 (instead of showing 0 through 199)

            Document pdfDocument = new Document(@"C:\test.pdf");
            var pdfPage = pdfDocument.Pages.Add();

            TextBuilder textBuilder = new TextBuilder(pdfPage);

            TextFragment textFragment = new TextFragment("some text");
            textBuilder.AppendText(textFragment);

            TextParagraph paragraph = new TextParagraph();
            for (int i = 0; i < 200; i++)
            {
                paragraph.AppendLine(i+" :\r\n");
            }
            
            textBuilder.AppendParagraph(paragraph);

            MemoryStream stream = new MemoryStream();
            pdfDocument.Save(stream, SaveFormat.Pdf);

            return stream;


I am using Aspose.pdf version 9.9.0.0

Thanks !!!

Image alignment issue inside textboxfield (form field)

$
0
0
Hi Team,

I am using ASPOSE.PDF API with DLL version 10.5.0.0.

I have a very simple requirement to bind image path inside textbox form field.
Image type is JPEG.

Issue is before using ASPOSE.PDF we were using ACTIVE PDF API and render of JPEG image is as expected consider a left align.

Once we migrate code to adept ASPOSE.PDF API, image render inside txtbox form field but with center align.
I tried every possible approach using ASPOSE still not able to resolve the issue.

Kindly assist and suggest your solution.

Logic: we are using Aspose.Pdf.InteractiveFeatures.Forms.TextBoxField
// Open documentDocument pdfDocument = new Document("input.pdf");// Get values from all fieldsforeach (Field formField in pdfDocument.Form)
{
  TextBoxField textBoxField= formField  as TextBoxField ;
textBoxField.HorizontalAlignment = HorizontalAlignment.Left;
textBoxField.addImage(System.Drawing.Image.FromFile(filepath));

 }

Using this Image is rendered inside textbox field but as center aligned.

We are not creating PDF from scratch so Generator API not applicable, we are working on byte[] and after filling input fields of type TextBoxField, we send back byte[] to consumer application.

Thanks & regards,
Amit Bisht

NullPointerException in the Form.importXml (First Time Only)

$
0
0

Hi there,

 

Aspose pdf version - aspose-pdf-10.3.0.jar

Platform – Fuse Windows, Fuse Linux

 We filling Fillable PDFs use  the following code in a camel route.

 The license is initialized as part of the spring bean afterPropertiesSet() method.

 

Document pdf = new Document(pdftemplateName);

       Formform = new Form();

       form.bindPdf(pdf);

       //import the changes to the pdf from xml stream

       InputStream xmlInputStream = xml input stream

       form.importXml(xmlInputStream);

       xmlInputStream.close();

    

       ByteArrayOutputStreambObj = new ByteArrayOutputStream();

  

       form.save(bObj);

       byte[] byteArray = bObj.toByteArray();   

The first time this code get executed we get the following null pointer exception. Successive runs of this method works for the same input xml.

java.lang.NullPointerException

at com.aspose.pdf.internal.p359.z32.m1(Unknown Source)

at com.aspose.pdf.internal.p361.z2.m1(Unknown Source)

at com.aspose.pdf.internal.p575.z11.m4(Unknown Source)

at com.aspose.pdf.internal.p575.z11.m7(Unknown Source)

at com.aspose.pdf.internal.p575.z11.m3(Unknown Source)

at com.aspose.pdf.internal.p575.z8.m1(Unknown Source)

at com.aspose.pdf.internal.p576.z12.m4(Unknown Source)

at com.aspose.pdf.internal.p576.z7.<init>(Unknown Source)

at com.aspose.pdf.internal.p576.z9.<init>(Unknown Source)

at com.aspose.pdf.internal.p576.z12.<init>(Unknown Source)

at com.aspose.pdf.internal.p575.z8.m1(Unknown Source)

at com.aspose.pdf.internal.p578.z27.m28(Unknown Source)

at com.aspose.pdf.internal.p578.z27.m1(Unknown Source)

at com.aspose.pdf.internal.p578.z29.m1(Unknown Source)

at com.aspose.pdf.internal.p578.z27.m1(Unknown Source)

at com.aspose.pdf.internal.p580.z1.m1(Unknown Source)

at com.aspose.pdf.internal.p579.z4.m1(Unknown Source)

at com.aspose.pdf.internal.p580.z1.m1(Unknown Source)

at com.aspose.pdf.internal.p580.z1.m2(Unknown Source)

at com.aspose.pdf.TextBoxField.m2(Unknown Source)

at com.aspose.pdf.WidgetAnnotation.m1(Unknown Source)

at com.aspose.pdf.Field.updateAppearances(Unknown Source)

at com.aspose.pdf.Field.m6(Unknown Source)

at com.aspose.pdf.Field.setValue(Unknown Source)

at com.aspose.pdf.TextBoxField.setValue(Unknown Source)

at com.aspose.pdf.facades.AForm.m2(Unknown Source)

at com.aspose.pdf.facades.AForm.importXml(Unknown Source)

at com.aspose.pdf.facades.Form.importXml(Unknown Source)


Input xml:

 <?xml version="1.0" encoding="UTF-8"?>

<fieldsxmlns:docfun="http://wwww.connecture.com/integration/docgen"
    xmlns:dyn="http://exslt.org/dynamic"xmlns:fn="http://www.w3.org/2005/xpath-functions"
    xmlns:gsp="http://groovy.codehaus.org/2005/gsp">
   
<field name="Applicant_Signature">
       
<value>PrimaryFName, PrimaryLName</value>
   
</field>
</fields>

 Thanks.

Cannot add new section after a multi-columns section

$
0
0
Got System.NullReferenceException when adding a new section which is not a page after another section which has an image inside.
var pdf = new Pdf();
const string webImgUrl = @"https://www.google.co.nz/images/srpr/logo11w.png";
var section = pdf.Sections.Add();
var img = new Image { ImageInfo = { File = webImgUrl, ImageFileType = ImageFileType.Png } };
section.Paragraphs.Add(img);
section.ColumnInfo.ColumnCount = 2;
section.Paragraphs.Add(new Text("Text 1"));

var thirdSection = pdf.Sections.Add();
thirdSection.IsNewPage = false;
using (var stream = new MemoryStream())
{
pdf.Save(stream);
using (var fileStream = File.Open(@"C:\temp\Image_Error.pdf", FileMode.Create))
stream.CopyTo(fileStream);
}

Need to create PDF from HTML having text, images n bullets

$
0
0
Present Implementaion for creating PDF from HTML string does not work properly for bullets and images. It crops the image and all bullets are converted to rectangular boxes. I am using  document builder insert html and save pdf methods. These work well without images and bullets

Dashed lines on PDF changing after PDF has stamp applied.

$
0
0
We make PDFs from AutoCAD drawings and as they go through their approval lifecycle, use Aspose.PDF to stamp them.
We have noticed a problem that some of the phantom/shadow lines (dashed lines) in the PDFs are changed during the stamping process, i.e. the output is different than the input. The stamp does not get near the lines.
I am attaching the input PDF (Linetest.pdf), and the ouput, stamped PDF (Linetest_stamp.pdf). For the lines that are changing, the linetype scale is getting smaller, and sometimes darker. Sometimes the dashes are so small and so close together they appear to be a solid line.
Referencing the output PDF (Linetest_stamp.pdf), all the lines in the leftmost figure change from input to output. In the middle figure, all the line except the center lines (the ones dissecting the circles) change. In the rightmost figure, none of the lines change. They are all center lines.

The uploaded file was stamped using Aspose.PDF 10.3.

Critical Memory leak in Aspose.PDF for .Net

$
0
0
Hi,
   This is a critical issue and an important functionality for our application.

There is a memory leak issue with XML using for PDF. The server process grows out to 1.5 from 300-400 MB and gives permission denied error on the pdf file. Attached is the XML file trying to convert. And below is the code to bind it using PDF object. 

Aspose.Pdf.License license = new Aspose.Pdf.License();
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
section.PageInfo.PageWidth = Aspose.Pdf.Generator.PageSize.A4Width;
section.PageInfo.PageHeight = Aspose.Pdf.Generator.PageSize.A4Height;
section.IsLandscape = true;

XmlDocument xd = new System.Xml.XmlDocument();
xd.LoadXml(inputDataLeftNav);

pdf.BindXML(xd, null);
pdf.Save("testfile.pdf");
pdf = null;

Insert existing PDF to new Aspose.PDF.Generator.PDF object

$
0
0
We use the Aspose PDF Generator for .NET in an MVC Application. I have a Aspose.PDF.GENERATOR.PDF object which I save to the output stream:

      //Save temporary file      pdf.Save(this.Response.OutputStream);      Response.ContentType = "application/pdf";      Response.AppendHeader("Content-Disposition""inline; filename=file.pdf");      return new EmptyResult();

Now we have to insert an uploaded PDF into our PDF which we create per code? Is this possible?

Best regards

Required packages for java

$
0
0
Hi,

 Greetings!
 We are evaluating pdf tool for one of our web application which runs in Java/J2EE.
 we came to know about aspose and wanted to check the feasibility of integration with application.
 below are few of our questions which we need some clarifications.
 . Html to pdf conversion

 . support for all standard html tags
 . editing the pdf file to add images at absolute position, replace text
 . support for multilingual(English and Arabic)
 . adding barcode generated to existing pdf file
 . appending pdf file to existing(merge two pdf files)
 . adding header/footer images
 .

 For supporting the above mentioned features, which all packages/licenses we need to purchase from Aspose and the cost of the packages.
 Please let us know the details on the product purchase and required licenses. And also we need technical support to write small pocs for the same.
 
 Thanks,
 Shivaji

PDFANDROID-176 (Text is not bold, line isn't seen)

$
0
0
Hello,

We are making an Android application that generates the pdf using some data.
We have used the Aspose.Pdf for Android 1.7.0 in our application.

Before we were using Aspose.Pdf for Android 1.6.0 and we saw that there are some bug fixes in the new version i.e 1.7.0 like (PDFANDROID-176    Text is not bold, line isn't seen) so we downloaded it and try to use in the application but we found that there was no difference and we are still not able to get the text bold and lines between rows are still missing. Also when we implemented the new version the time it took to generate the pdf increased as compared to 1.6.0 . So we are not getting which version is more helpful and which to use. Please do need full for the same.

Sample Code
TextState m_headerState = new TextState();
m_headerState.setFontSize(m_headerTitleSize);
m_headerState.setForegroundColor(com.aspose.java.awt.Color.BLACK);
m_headerState.setFontStyle(FontStyles.Bold);


Thanks

Saving pdf document to doc(x) causes NullPointerException

$
0
0
Hello,

When trying to save the attached pdf file as doc(x), a NullPointerException is thrown back.

Version: 10.2.0 for Java.
Error reproduced on: Ubuntu and Red Hat Linux.
Example code:
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document("<full path>/emd-2009-043098.pdf");
pdfDocument.save("/tmp/tempname.doc", SaveFormat.DocX);

PDF-to-Word - string index out of bounds

$
0
0
Hello, I'm using Aspose PDF 10.4.1 to convert PDF to Word (via ColdFusion):
<cfset var docSaveOptions=createObject("java","com.aspose.pdf.DocSaveOptions").init()>
<!-- doc: 0, docx: 1 --->
<cfset docSaveOptions.setFormat(1)>
<!--- textbox: 0, flow: 1 --->
<cfset docSaveOptions.setMode(1)>
<cfset docSaveOptions.setRecognizeBullets(true)>
<cfset pdf=createObject("java","com.aspose.pdf.Document").init(tempFile)>
<cfset pdf.decrypt()>
<cfset pdf.save(tempDocXFile,docSaveOptions)>
<cfset pdf.close()>
On the attached file, in Aspose PDF10.3.x, the file converted but all the letters were upside down.  When we upgraded to 10.4.1, we get an error:

String index out of range: 437
StackTrace java.lang.StringIndexOutOfBoundsException: String index out of range: 437 at java.lang.String.charAt(Unknown Source) at com.aspose.doc.ml.MlParagraphConverter.addParagraph(Unknown Source) at com.aspose.doc.ml.Wbody.accept(Unknown Source) at com.aspose.doc.ml.Wdocument.accept(Unknown Source) at com.aspose.doc.ml.DocxConverter.convert(Unknown Source) at com.aspose.pdf.internal.p687.z8.m15(Unknown Source) at com.aspose.pdf.internal.p37.z2.m1(Unknown Source) at com.aspose.pdf.z19.m1(Unknown Source) at com.aspose.pdf.ADocument.m1(Unknown Source) at com.aspose.pdf.Document.m1(Unknown Source) at com.aspose.pdf.ADocument.save(Unknown Source) at com.aspose.pdf.Document.save(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Please advise.  Thank you.
Viewing all 1038 articles
Browse latest View live