I want to create a pdf file in my Android app.
What is the difference between these two classes ?
https://developer.android.com/reference/android/graphics/pdf/PdfDocument
https://developer.android.com/reference/android/print/pdf/PrintedPdfDocument.html
Thanks !
Related
I am new in android programming and I am struggeling with saving an existent CSV file. I wrote the Code with Java in Processing. and it works on the PC but now I would like to switch to android Mode - but how can I Move the CSV file to my phone? and is there an easy way so i can use the Command:
table = loadTable("Vocstest.csv", "header");
I use Processing 3.37
The code you wrote will work just fine on an android phone. I have used the same code as yours in an app.
The difference may be that i do not try to override it (by saving) I am only accessing it to retrieve the data.
You have to add your file in the "data" directory in your project. If the "data" folder does not exist you can create it and put in your csv file.
example:
Table aQaK = loadTable("aQaK_ar.csv", "header");
TableRow myrow = aQaK.getRow(myversenum);
String myversetxt = myrow.getString("AyahText");
Hope this helps. Peace.
We create PDF files with iText (in Java) which are working fine on Windows / Android, however when we open such file on an iPhone the acroFields that were set in the code are empty.
We are using the following code and the setGenerateAppearances is already set to true.
PdfStamper pdfStamper = new PdfStamper(templateReader, pagePdf);
AcroFields acroFields = pdfStamper.getAcroFields();
acroFields.setGenerateAppearances(true);
acroFields.setField("creationdate", creationDate);
Any idea why this isn't working on the iPhone but it does work on all other devices?
Thanks
As stated by Bruno Lowagie, the issue can be resolved by using the flatten option, which should be set before the pdfStamper.close() has been called:
// flatten the PDF (so the values are visible when PDF is downloaded on iOS / OS X)
pdfStamper.setFormFlattening(true);
I would like to open a PDF File inside an existing Java(SWT)-Application. The PDF should not opened in an external frame. I tried via the OLE interface but without success.
clientSite = new OleControlSite(frame, SWT.NONE, "AcroExch.App", fileName);
automation = new OleAutomation(clientSite);
clientSite.doVerb(OLE.OLEIVERB_OPEN);
you can use the IE Interface and then navigate to the PDF file.
Pseudocode:
$Obj = ObjCreate("Shell.Explorer.2")
$Obj.Navigate('D:\Test.pdf')
or the Reader Web Interface
Pseudocode:
$oReader = ObjCreate("AcroPDF.PDF.1")
$oReader.Load("D:\Test.pdf")
How you bind the object into your Java-GUI you may ask under java
HTH, Reinhard
PS: the "Shell.Explorer.2" option mostly works for me better.
In my new app I wanted to make an IO object that will help me access text files written in a raw folder located in the res folder.
The object is a java class that is written in the same location as all of the rest java files.
The goal of this object is that I can access files from all of the activities instead of writing them again and again.
But when I tried to do that I stumbled upon a few errors that I can't find a way to fix them.
While writing the code:
FileOutputStream fos = new FileOutputStream(R.raw.fName);
(fName is a Sting that the action receives)
Android studio marked the "raw" red and said it didn't recognize it.
From what I understand the R file doesn't recognize the raw folder.
The second problem is , when I write the code:
InputStream is = Context.this.getResources().openRawResource(R.raw.fName);
It still gives me an error at the raw and an error at "Context.this" , and asks me to split the deceleration or to surround it with a try block , which doesn't help. And at the headline there is a throws IOException so any errors with IO should be cleared.
And if there is an easier way to access actions in java files , a link or an explanation will help a lot.
P.S. a raw folder is a premade folder with premade text files , also an easier way to read and write in premade files will help.
I want to print a doc file using java. How can i do it without any 3rd party API.
As far as i know, you have to render the doc file as image and then pass it to the printer. Is there any way to render the doc file in image and then print it?
You need not convert the document to an image. If you are using Java 6+, you can try:
File file = new File("C:\\document.doc");
Desktop.getDesktop().print(file);
The method print in the class java.awt.Desktop:
Prints a file with the native desktop printing facility, using the associated application's print command.