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

Convert XFA pdf to a standard PDF

$
0
0

Hi,

I try to convert a XFA pdf to a standard flatten pdf.

i try this :

  Aspose.Pdf.Document document = new Aspose.Pdf.Document(fileName);
//    document.Form.Type = Aspose.Pdf.InteractiveFeatures.Forms.FormType.standard;
  document.Flatten();
  document.Save(FileNameOut);

 

If i force the type to Standard, apose create an exeption (see attach)

 

Without this form.type, a pdf is create but javascrip is allways in the pdf destination.

How can I convert xfa pdf  ?

Thks.

 

 

 

 

 

 

 


Saved document contains invalid xref table

$
0
0
When I open and then save a PDF, the resulting PDF contains an invalid xref table.
I tested this with the newest version (10.2.0.0)
Older versions of Aspose.Pdf do not have this problem (7.7.0.0 is working fine)

This is a big problem for us. I hope you can solve it with high priority.

Best regards, 
Corné Los - Solipsis

You can reproduce the problem like this:

var document = new Aspose.Pdf.Document("in.pdf");
document.Save(@"out.pdf");

The xref table in out.pdf looks like this:

xref
0 12
0000000000 65535 f
0000000018 00000 n
0000000070 00000 n
0000000145 00000 n
0000000257 00000 n
0000000355 00000 n
0000000528 00000 n
0000000548 00000 n
0000001753 00000 n
0000001861 00000 n
0000001928 00000 n
0000002109 00000 n
13 1               <-- This is incorrect
0000002131 00000 n


How to use aspose.pdf to justify text

$
0
0
Hi, I'm new to Aspose and a competent user of SSRS but not advanced. I'm evaluating Aspose and wonder how I add code to justify text in a textbox? I have searched the site and can't see anything that describes step by step how to achieve this. The closest I've found is for 2005 below but am using 2008 R2.

The code example was (where does it go in 2008 R2?):
<Textbox Name="textbox1">
	......<Style>
      ......</style><value> AsposePdf4RS </value><CustomProperties><CustomProperty><Name>Footnote</Name><Value> An optional PDF renderer for SSRS from Aspose</Value></CustomProperty></CustomProperties></Textbox> 

Link Annotation text color change issue

$
0
0
Hello,

We have purchased Aspose.PDF license and implementing pdf functionality in one of our project. As per our requirement we need to change link annotation color to red for specific text in the document. After going through one of your reference we have implemented the functionality. But the color is changing for some text in one page but not in another page for same document.

Here is the code we are using.

        Aspose.Pdf.License license = new Aspose.Pdf.License();
        license.SetLicense("Aspose.Pdf.lic");
        Aspose.Pdf.Document doc = new Aspose.Pdf.Document(filePath);
        int noofpages1 = 0;
        noofpages1 = doc.Pages.Count;
        for (int p = 1; p <= noofpages1; p++)
        {
            Aspose.Pdf.Page page = doc.Pages[p];
            AnnotationSelector selector = new AnnotationSelector(new Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation(page, Aspose.Pdf.Rectangle.Trivial));
            int height72Dpi = 792;
            page.Accept(selector);
            IList list = selector.Selected;
            if (list.Count > 0)
            {
                foreach (LinkAnnotation a in list)
                {
                    
                        try
                        {
                            Aspose.Pdf.InteractiveFeatures.Annotations.Border border = new Aspose.Pdf.InteractiveFeatures.Annotations.Border(a);
                            //llx = Convert.ToInt32(a.Rect.LLX);
                            //urx = Convert.ToInt32(a.Rect.URX);
                            //lly = Convert.ToInt32(height72Dpi - a.Rect.LLY);
                            //ury = Convert.ToInt32(height72Dpi - a.Rect.URY);
                            //Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation link = new Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation(page, new Aspose.Pdf.Rectangle(llx, height72Dpi - lly, urx, height72Dpi - ury));
                            TextFragmentAbsorber ta = new TextFragmentAbsorber();
                            Aspose.Pdf.Rectangle rect = a.Rect;
                            rect.LLX -= 10;
                            rect.LLY -= 10;
                            rect.URX += 10;
                            rect.URY += 10;
                            ta.TextSearchOptions = new TextSearchOptions(rect);
                            ta.Visit(doc.Pages[p]);
                            // Change color of the text.

                            foreach (TextFragment tf in ta.TextFragments)
                            {
                                tf.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red);
                                border.Width = 0;
                            }
                            //}
                        }
                        catch (Exception exp)
                        {
                        }
                    
                }
            }

        }

        doc.Save(filePath);

These are the scenarios we have tested.

1) The attachment document "bookmarks.pdf" contains some links with blue color which we wanted to change the color to red. But it is not happening. 

2)The document "DVI-7310_Data.PDF" first page right side cornor text "DVI-7310" is getting updated with red color but remaining text "Single-Link DVI Fiber Optic Extender" is not getting updated. We have made some other links also on the same page those are working fine. 

Could you please let us know the resolution for this problem.

using IsVerticalBroken and VerticalTextRotationType.AntiClockWise causes formatting issue

$
0
0

Good Morning,

 

I am creating a set of tables using the PDF Generator whose cells in column 1 (the headers) are set as follows:

headerCell.VerticalTextRotationAngle = VerticalTextRotationType.AntiClockWise;

headerCell.VerticalAlignment = VerticalAlignmentType.Center

headerCell.Alignment = AlignmentType.Left;

Some of these are single cells with vertical text, and some are cells with a nested table which display a name displayed vertically (ex. Time in Seat) and a set of periodicity measurements (ex.  30/60/90) displayed horizontally at the bottom.

All of the tables use the same code to generate the tables, and the first set of headers (in white) are common across all tables, with the blue and gray being added on dependent upon the Subject's requirements.  Also, the section holding all of the tables has the isLandscape option set to true.

On occasion, some of the tables extend past the page length, so I set the isVerticalBroken option for the table to true.  However, the combination of Anticlockwise and isVerticalBroken seems to throw off the formatting (see the tables for subject 0 and Subject 1).   If the table fits within the page, the formatting is fine (Subject 1), but if the table extends past the end of the page, triggering a vertical split, the formatting becomes incorrect.

Can you provide me with any advice on how to correct the problem?  Also, is there any way to repeat column1 on vertical split?  

Thank you in advance for your help in this matter.

V/R,

Cunning

 

 

 

 

 

HTML to PDF External CSS Issues

$
0
0
Hi, 

Right now I am trying to convert a HTML file with an external css file to PDF. However, the css doesn't seem to be applied to the PDF. I have tried using an absolute path for the css file but it does not seem to work. I was wondering if there was a solution to this problem somewhere? Thanks.

FreeTextAnnotation does not appear until it is resized

$
0
0
I am attempting to add a a FreeTextAnnotation to an existing PDF that will only show on the PDF when printing, following the example at the bottom of the page here: http://www.aspose.com/docs/display/pdfnet/Add+Annotation+in+an+Existing+PDF+File

When I printed the PDF, the annotation did not show up, so I removed the AnnotationFlags.NoView flag. After that, the annotation did not show up when opening the file in Acrobat, but if I clicked around where the annotation should have been, a box would be highlighted. If I resized the box, the annotation would then appear.

To make sure this wasn't an issue with my code, I checked the annotation examples in the Aspose Examples Dashboard to see if I experienced the same issue. I ran the example Aspose.Pdf/Programmers Guide/Working with Annotations/Set Formatting of FreeTextAnnotation. The exact same issue occurred. See attachments for pictures of the issue on the file generated by the Aspose example.

I am running Windows Server 2012 and the latest version of Adobe Acrobat XI. Others in my office tried the same file and experienced the same issue. All of them are using Acrobat XI and Server 2012/ Windows 8.1/ Server 2008 R2.

What we need is for a) the FreeTextAnnotation to show up without resizing the box if the NoView flag is not set, and b) the FreeTextAnnotation to show up on printed paper if the Print flag is set.

Out of Memory Exception Creating PDF

$
0
0
Hi,

We are running in to a System.OutOfMemoryException when attempting to create a PDF file from HTML.

Our code has been working fine for months, however this particular conversion is causing us issues. Oddly enough, this particular conversion is working in our production environment, but not when debugging. Further, the issue is not limited to one developer since other developers were able to reproduce the issue.

Here is the code:

{
Pdf pdf = new Pdf {HtmlInfo = {ImgUrl = anImageUrl}};

Section section = pdf.Sections.Add();
section.IsLandscape = isLandscape;

Text text = new Text(section, anHtml);
text.IsHtmlTagSupported = true;

// Add page margins
Aspose.Pdf.Generator.MarginInfo marginInfo =
new Aspose.Pdf.Generator.MarginInfo
{
Top = PDF_MARGIN_TOP,
Bottom = PDF_MARGIN_BOTTOM,
Left = PDF_MARGIN_LEFT,
Right = PDF_MARGIN_RIGHT
};
section.PageInfo.Margin = marginInfo;

section.Paragraphs.Add(text);

Document document = new Document(pdf); //Out of Memory exception on this line

...
...

}

In case you need the HTML for testing purposes, I have attached a scrubbed version of it as a text file.

After upgrade to 10.3, imported TIFFs are marked with 'evaluation only'

$
0
0
Hi,

I upgraded Aspose.Pdf from 9.7 to 10.3, and after the upgrade, my imported tiff images in pdf show with a watermark:


Evaluation only
Created with Aspose.Imaging


Our Aspose.Pdf license is up to date (extended for another year of updates a month ago). All other Pdf features we use work just fine.

Is imaging a separate license in 10.3?

TextFragmentAbsorber and regular expressions

$
0
0
Hi. I'm evaluating aspose to do document anonymisation - eg replace names with XXX.
I'm testing with:

private static void replace(Document pdfDocument, String oldString, String newString, ) {
    System.out.println("replace: " + oldString + " as: " + newString);
    TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(oldString);
    pdfDocument.getPages().accept(textFragmentAbsorber);
    TextFragmentCollection textFragmentCollection = textFragmentAbsorber.getTextFragments();
    for (com.aspose.pdf.TextFragment textFragment : (Iterable<com.aspose.pdf.TextFragment>) textFragmentCollection)
    {
        System.out.println("Replacing occurrence of: " + oldString + " as: " + newString + " in:"+textFragment.getText()+".");
        textFragment.setText(newString);
    }
    }

Testing with e.g. "John Smith" -> XXX

However there are occurrences that are recognised while others not (e.g. "Jonh Smith" found, "Johanna Doe" not). Obviously text search within acrobat find both ... Cannot attach the test pdf file due to privacy issues on names .. Anyone already found problems like this? Any hint?

Justify only seems to work with one sub report

$
0
0
Hi I have a report that has several different sub-reports on it.

When I have a single instance of a sub report that will justify the text it seems to work fine - If I place another copy of this report into the main report neither this sub-report or the previously justifying sub report now justify!


I really need to get this working - It's been nearly a year and a half trying to get this working 

Regards
Andy

How to calculate dpi.

$
0
0
Hi Team,

According to our requirement we are converting Pdf file into Images and displaying on the browser, 
we are displaying the pdf annotations as links on the browser using javascript. In this scenario we took 72 dpi by default its displaying the links on he browser acurately with pdf  annotations co-ordinates. when the pdf document is landscape or A3. It is not displaying the links accurately with pdf annotation co ordinates. 

Please help us how to calcuate dpi with pdf document size.

Diagonal text watermark that appears only when printing?

$
0
0
Is it possible to have a text watermark/ annotation that only appears when printing, that goes diagonally across the page from bottom left to top right?

It seems like we would want to use the FreeTextAnnotation for this, since that supports the NoView and Print annotation flags. However, I don't see a way to make this text diagonal.

Alternatively, it appears a TextStamp would allow us to set an angle for the text, but has no support for making the text only appear when printing.

An example of how we are trying to format the text is attached.

Apsose pdf introduces space when the pdf document has chinese characters

$
0
0
Hi, 

I am trying to extract text from a pdf document. The pdf document has some chinese characters. So when I use the text absorber, I am seeing that it introduces unnecessary spaces between the characters.

private String extractText(byte[] inputContent) throws IOException{

ByteArrayInputStream stream = new ByteArrayInputStream(inputContent);

Document pdfDocument = new Document(stream);

// Create TextAbsorber object to extract text

TextAbsorber textAbsorber = new TextAbsorber();

// Accept the absorber for all the pages

pdfDocument.getPages().accept(textAbsorber);

// Get the extracted text

String extractedText = textAbsorber.getText();

returnextractedText;

}


I am also attaching the java code and the pdf file.

Adding Image to PDF Does Not Maintain Aspect Ratio

$
0
0
I have code that takes a list of documents (PDFs, image files, Word Docs, etc) and appends each into one single PDF.

It has been pointed out to me that when an image that is larger than the page is appended, the aspect ratio is not preserved and the image looks undesirable.

I have looked for more examples without much luck.

I have extracted the code out into a simple Widows Forms application that is attached.

Can you advise me how I can accomplish this?  I tried zipping my project, but the 29 MB file could not be attached.  I have attached a sample image and here is the code:

            string docName = @"14-8158_DSC_850120140721092109.jpg";

            Aspose.Pdf.Document masterDoc = new Aspose.Pdf.Document();

            Document pdfDoc = new Aspose.Pdf.Document();
            Page page = pdfDoc.Pages.Add();
            FileStream imageStream = new FileStream(docName, FileMode.Open);

            Bitmap tempimage = new Bitmap(imageStream);
            double urx = tempimage.Width;
            double ury = tempimage.Height;
            //page.Rect.URX = urx;
            //page.Rect.URY = ury;
            page.Resources.Images.Add(imageStream);
            page.Contents.Add(new Operator.GSave());
            Aspose.Pdf.Rectangle pagerect = page.Rect;
            if (tempimage.Width > pagerect.URX)
                urx = pagerect.URX;
            if (tempimage.Height > pagerect.URY)
                ury = pagerect.URY;
            Aspose.Pdf.Rectangle rectangle = new Aspose.Pdf.Rectangle(0, 0, urx, ury);
            //Matrix matrix = new Matrix(new double[] { rectangle.URX - rectangle.LLX, 0, 0, rectangle.URY - rectangle.LLY, rectangle.LLX, rectangle.LLY });
            Matrix matrix = new Matrix(new double[] { rectangle.URX - rectangle.LLX, 0, 0, rectangle.URY - rectangle.LLY, rectangle.LLX, rectangle.LLY });
            page.Contents.Add(new Operator.ConcatenateMatrix(matrix));
            XImage ximage = page.Resources.Images[page.Resources.Images.Count];
            page.Contents.Add(new Operator.Do(ximage.Name));
            page.Contents.Add(new Operator.GRestore());
            masterDoc.Pages.Add(pdfDoc.Pages);
            imageStream.Close();
            imageStream.Dispose();

            masterDoc.Save("TestPdfImage.pdf");

            System.Diagnostics.Process.Start("TestPdfImage.pdf");

Manipulate PDF Document

$
0
0
Our company has a generous amount of existing PDF files that we are looking at dynamically manipulating from asp.net website. I see in the examples where it is possible to open existing PDF file and input text, tables and form elements. We need to retain the existing format structure/layout of our PDF files. My idea is that we would modify our PDF files and insert place holder text. We would then use PDF.namespace to open the files and then programmatically replace the place holder text with dynamic text, table and form elements using PDF.namespace? This would allow us to retain format structure, and simply "find and replace" the place holder text with dynamically generated content programmatically. I believe this would save us time over using the PDF.Generator to generate each document dynamically, eliminating to the need to tediously build the entire document structure. Thank you!

Text exctraction from pdf form produces empty text

$
0
0
Hello,

text extraction from the attached pdf form produces only empty strings.

Aspose.Pdf.dll 10.3.0.0
bugid#7231

Best regards, Martin Pfeifer

CSHTML with pie chart not shown in Aspose.Pdf conversion

$
0
0
We have been using Aspose.Pdf 7.6.0 converting .cshtml to .pdf in our c# MVC.

The Aspose.Pdf can't seem to render the pie chart we have in our CSHTML.  It's as simple as:
https://developers.google.com/chart/interactive/docs/gallery/piechart#3D

I tried to convert whatever I have in my index.html to index.pdf generating a 2D graph but no luck.

----------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 <title> Pie </title>
 <meta name="Generator" content="EditPlus">
 <meta name="Author" content="">
 <meta name="Keywords" content="">
 <meta name="Description" content="">
</head>
<body>
<style>
   .pieContainer {
         height: 100px;
    }
    .pieBackground {
         background-color: grey;
         position: absolute;
         width: 100px;
         height: 100px;
         -moz-border-radius: 50px;
         -webkit-border-radius: 50px;
         -o-border-radius: 50px;
         border-radius: 50px;
         -moz-box-shadow: -1px 1px 3px #000;
         -webkit-box-shadow: -1px 1px 3px #000;
         -o-box-shadow: -1px 1px 3px #000;
         box-shadow: -1px 1px 3px #000;
    }
    .pie {
         position: absolute;
         width: 100px;
         height: 100px;
         -moz-border-radius: 50px;
         -webkit-border-radius: 50px;
         -o-border-radius: 50px;
         border-radius: 50px;
         clip: rect(0px, 50px, 100px, 0px);
    }
    .hold {
         position: absolute;
         width: 100px;
         height: 100px;
         -moz-border-radius: 50px;
         -webkit-border-radius: 50px;
         -o-border-radius: 50px;
         border-radius: 50px;
         clip: rect(0px, 100px, 100px, 50px);
    }
 
    #pieSlice1 .pie {
         background-color: #1b458b;
         -webkit-transform:rotate(150deg);
         -moz-transform:rotate(150deg);
         -o-transform:rotate(150deg);
         transform:rotate(150deg);
    }
    #pieSlice2 {
         -webkit-transform:rotate(150deg);
         -moz-transform:rotate(150deg);
         -o-transform:rotate(150deg);
         transform:rotate(150deg);
    }
    #pieSlice2 .pie {
         background-color: #ccbb87;
         -webkit-transform:rotate(40deg);
         -moz-transform:rotate(40deg);
         -o-transform:rotate(40deg);
         transform:rotate(40deg);
    }
    #pieSlice3 {
         -webkit-transform:rotate(190deg);
         -moz-transform:rotate(190deg);
         -o-transform:rotate(190deg);
         transform:rotate(190deg);
    }
    #pieSlice3 .pie {
         background-color: #cc0000;
         -webkit-transform:rotate(70deg);
         -moz-transform:rotate(70deg);
         -o-transform:rotate(70deg);
         transform:rotate(70deg);
    }
    #pieSlice4 {
         -webkit-transform:rotate(260deg);
         -moz-transform:rotate(260deg);
         -o-transform:rotate(260deg);
         transform:rotate(260deg);
    }
    #pieSlice4 .pie {
         background-color: #cc00ff;
         -webkit-transform:rotate(100deg);
         -moz-transform:rotate(100deg);
         -o-transform:rotate(100deg);
         transform:rotate(100deg);
    }
</style>
 
<div class="pieContainer">
    <div class="pieBackground"></div>
    <div id="pieSlice1" class="hold"><div class="pie"></div></div>
    <div id="pieSlice2" class="hold"><div class="pie"></div></div>
    <div id="pieSlice3" class="hold"><div class="pie"></div></div>
    <div id="pieSlice4" class="hold"><div class="pie"></div></div>
</div>
    
 </body>
</html>

--------
C# Code:
                HtmlLoadOptions htmlOptions = new HtmlLoadOptions("c:/temp/");
                Document doc = new Document("c:/pdftest/chart.html", htmlOptions);
                doc.Save("c:/temp/convert_chart.pdf");

CPU and Memory performance problems

$
0
0
Hello,

We work for a company which uses both Aspose PDF and Words for Java in developed web applications. The current versions we use are:
  • Aspose PDF 9.7.0
  • Aspose Words 14.9.0

We have detected many problems in our servers which many threads of Aspose Pdf (and some of Aspose Words) get stuck while working with documents. These problems appears when users work with documents at same time, so we cannot attatch the "problematic" documents. These threads never ends and stay running consuming CPU until we kill the java process.

Here is an snapshot of Java Mission Control when these problems appear, threads with the highest cpu usage (Total CPU Usage) are the ones using Aspose and it consumes lots of memory as you can see in column Allocated Bytes, and you can see that the stack trace occurs on Aspose code:



Our servers run SUSE Linux Enterprise Server 11 (x86_64) (4 CPU + 16GB RAM), JDK 1.7.0_45, with Tomcat 7.0.29.
The current JVM parameters are the following:
$JAVA_OPTS -D64 -Xmx12G \
        -Dfile.encoding=UTF8 -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false \
        -XX:MaxPermSize=1G \
        -Djava.security.auth.login.config=/srv/support/gssapi.conf \
        -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=5000 \
        -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false \
        -Dorg.apache.el.parser.COERCE_TO_ZERO=false \
        -Djava.library.path=/srv/apache-apr-1.4.6/lib


Could you please help us with this issue, recommending us witch version of Aspose is the most stable for production environment and which JVM Opts are the best for heavy use of Aspose PDF and Aspose Words in web apps.

Thank you in advance.

PDF-Android: reading and identifying form fields

$
0
0
I get the form fields using the following code:

String fPath = "whatever...pdf";

com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(fPath);

PageCollection pages = pdfDocument.getPages();

for (int i = 1; i <= pages.size(); i++){

Page page = pages.get_Item(i);

com.aspose.pdf.Form form = document.getForm();

com.aspose.pdf.Field[] fields = form.getFieldsInRect(page.getRect());

if(null != fields){

for(Field fld : fields){   

// get field info here

}

}

}

My questions:

1. How do I know if a field is TextField, or a CheckBox, or a Button, etc?

2. When I read coordinates of a field like: 

double x_ = fld.getRect().getLLX();

double y_ = fld.getRect().getLLY();

it gives me values if the fields were "vertically flipped". E.g. if field A is located near to top (say: x=10, y = 10), the above code would give me coordinates close to the bottom. If the page height was 500 then I would get x_ = 10, y_ = 490. How should I interpret it?


Viewing all 3131 articles
Browse latest View live


Latest Images