Java を使用して PDF ドキュメントにテキストを書き込む必要があります。そのためのコードを書きました。しかし、私はファイルを開くことができません。アイデアがあれば、私と共有してください。
public class WritPDF
{
public static void main(String[] args)
{
Writer writer = null;
try
{
String text = "This is a text file";
File file = new File("C:/Users/PrinterTest/Hi1.pdf");
writer = new BufferedWriter(new FileWriter(file));;
writer.write(text);
} catch (FileNotFoundException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
} finally
{
try
{
if (writer != null)
{
}
} catch (IOException e)
{}
}
}
}